package com.deng.mapper;

import com.deng.pojo.User;
import org.apache.ibatis.annotations.*;

/**
 * @create 2020-12-15 15:12
 */
@Mapper
public interface UserMapper {
    @Select("select u.id,u.name,u.pwd from t_user u where u.name=#{username}")
    @Results({@Result(property = "username", column = "name"),
            @Result(property = "password", column = "pwd"),
            @Result(property = "id", column = "id")})
    User findUserByName(@Param("username") String username);

    @Insert("insert into t_user(name,pwd) values(#{username},#{password})")
//    @Options(useGeneratedKeys = true,keyProperty = "u_id",keyColumn = "id")
    int regist(@Param("username") String username, @Param("password") String password);

    @Select("select u.id,u.name,u.pwd from t_user u where u.name=#{username} and pwd=#{password}")
    @Results({@Result(property = "username", column = "name"),
            @Result(property = "password", column = "pwd"),
            @Result(property = "id", column = "id")})
    User login(@Param("username") String username, @Param("password") String password);
}
